package mainBoerse;

import java.util.ResourceBundle;

import exceptions.NotEnoughMoneyException;


public class CashAccount extends Asset {
	
	
	public CashAccount(long money, String name) {
		
		this.value = money;
		this.name = name;
		
	}

	@Override
	public float getValue() {
		
		return this.value;
	}
	
	
	public String toString(ResourceBundle prop) {
		return "Ihr Gelddepot:" + this.value + " " + prop.getString("currency") + "<br>Ihr Gelddepot Name: "+(this.name) + "<br>";
	}
	
	public void setValue(float value) {
		this.value = value;
	}
	
	
	public void reduceMoney(int count, float money)
			throws NotEnoughMoneyException {

		if (this.value >= (count * money)) {
			this.setValue(this.value
					- (count * money));
			//System.out.println("Kauf erfolgreich");
		} else {
			throw new NotEnoughMoneyException(
					"Not enough money to buy in player.reducemoney");

		}
	}
	
	public void addMoney(int count, float money) {

		this.setValue(this.value + (count * money));
	}




}
